package com.wanxi.set;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class StringLengthSort {
    public static void main(String[] args) {
//        Set<String> set = new TreeSet<>((o1, o2) -> o1.length() - o2.length()==0?o1.compareTo(o2):o1.length() - o2.length());
        Set<String> set = new TreeSet<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                if (o1.length() - o2.length() == 0) {
                    return o1.compareTo(o2);
                } else {
                    return o1.length() - o2.length();
                }
//                return o1.length() - o2.length()==0?o1.compareTo(o2):o1.length() - o2.length();
            }
        });
        set.add("c");
        set.add("ab");
        set.add("df");
        set.add("qwer");
        System.out.println(set);
    }
}
